import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/main.css'
import 'element-ui/lib/theme-chalk/index.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
import dateFormat from './assets/time'
// 引入Nprogress js和css
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

//  富文本框
import VueQuillEditor from 'vue-quill-editor'

// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.use(VueQuillEditor)

Vue.component('tree-grid', ZkTable)

Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截
axios.interceptors.request.use(config => {
  // console.log(config)
  Nprogress.start() // 请求时进度条显示
  config.headers['Authorization'] = sessionStorage.getItem('token')
  return config // 必须加上
})
// 响应拦截
axios.interceptors.response.use(config => {
  Nprogress.done() // 响应时进度条隐藏
  return config 
})
Vue.config.productionTip = false
// 定义全局过滤器 对日期处理
Vue.filter('dateFormat', function (date, format) {
  return dateFormat(date, format)
})
// 注册全局过滤器
import * as filters from './filters/index' // 全局过滤器

Object.keys(filters).forEach(key => {
        Vue.filter(key, filters[key])
    })
new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
